package com.linwen.excise.niuke._120;

import java.util.*;

/**
 * @author wlw
 * @date 2023/3/18 12:29 AM
 */
public class _102字符统计 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        char[] chars = str.toCharArray();
        HashMap<Character, Integer> map = new HashMap<>();
        for (char aChar : chars) {
            map.put(aChar,map.getOrDefault(aChar,0)+1);
        }
        List<Node> list = new ArrayList<>(map.size());
        map.forEach((key,value)->{
            list.add(new Node(value,key));
        });
        Collections.sort(list, (o1, o2) -> {
            if(o2.count!= o1.count){
                return o2.count- o1.count;
            }
            return o1.aChar- o2.aChar;
        });
        for (Node node : list) {
            System.out.print(node.aChar);
        }

    }
    static class Node{
        int count;
        char aChar;
        Node(int count,char aChar){
            this.count = count;
            this.aChar = aChar;
        }
    }
}
